package com.hh.poidemo;

import java.io.FileOutputStream;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Test;

public class POIDemo1 {
	@Test
	public  void test3() throws Exception {
		HSSFWorkbook work = new HSSFWorkbook();
		HSSFSheet sheet = work.createSheet("hu");
		HSSFRow row = sheet.createRow(0);
		for (int i = 0; i < 3; i++) {
			HSSFCell cell = row.createCell(i);
			cell.setCellValue("xili");
		}
		FileOutputStream fos = new FileOutputStream("e:/3.xls");
		work.write(fos);
		fos.close();
		work.close();
		System.out.println("导出成功！");
	}
	@Test
	public void test() throws Exception {
		SXSSFWorkbook work = new SXSSFWorkbook();
//		Workbook work = WorkbookFactory.create(new File("e:/0.xlsx"));
		Sheet sheet =  work.createSheet("first table");
		Row row = sheet.createRow(0);
		for (int i = 0; i < 3; i++) {
			Cell cell = row.createCell(i);
			cell.setCellValue("xili");
		}
		FileOutputStream fos = new FileOutputStream("e:/1.xls");
		work.write(fos);
		fos.close();
		work.close();
		System.out.println("导出成功！");
	}
	@Test
	public void test1() throws Exception{
		XSSFWorkbook work = new XSSFWorkbook();
		XSSFSheet sheet = work.createSheet("second table");
		XSSFRow row = sheet.createRow(0);
		for (int i = 0; i < 3; i++) {
			Cell cell = row.createCell(i);
			cell.setCellValue("xili");
		}
		FileOutputStream fos = new FileOutputStream("e:/1.xlsx");
		work.write(fos);
		fos.close();
		work.close();
		System.out.println("导出成功！");
	}
}
